﻿@model SmallJob.Model.Request
@{
    ViewBag.Title = Resources.Resource.AddRequestTitle;
    Layout = "~/Views/Shared/_Layout2.cshtml";
    var listCate = ViewData["AllCate"] as List<SmallJob.Model.Category>;
}
<div class="service-detail">
    <div class="service-detail-container">
        <div class="row-fluid">
            <div class="span8 service-detail-box main-column">
                <div class="inner">
                    <h1 class="muted text-center vn-modal-headline">Thông tin yêu cầu</h1>
                    @if (TempData["mess"] != null)
                    {
                        <div class="alert alert-success">
                            @TempData["mess"].ToString() <a href="@Url.Action("Details", "Request", new { id = Convert.ToInt32(TempData["rID"]) })">Bấm vào đây</a> @(Model.ID == 0 ? "để xem yêu cầu bạn vừa đăng!" : "để xem yêu cầu bạn vừa thay đổi!")
                        </div>
                    }
                    @using (Html.BeginForm("Save", "Request", FormMethod.Post, new { Class = "form-horizontal", id = "form-request", name = "form", enctype = "multipart/form-data" }))
                    {
                        @Html.Hidden("id", Model.ID)
                        <fieldset>
                            <div id="group-title" class="control-group">
                                <div class="controls service-add-input">
                                    <div class="input-prepend input-fullwidth">
                                        <span class="add-on">Tiêu đề</span>
                                        <div class="input-wrapper">
                                            <input name="title" class="input-large" value="@Model.Title" placeholder="Tiêu đề yêu cầu" type="text">
                                        </div>
                                    </div>
                                    <span class="help-inline"></span>
                                </div>
                            </div>
                            <div id="group-description" class="control-group">
                                <div class="controls service-add-input">
                                    <div class="input-prepend">
                                        <label>Mô tả yêu cầu</label>
                                        <textarea rows="6" style="width: 585px; height: 300px" name="description" id="area-des">@HttpUtility.HtmlDecode(Model.Description)</textarea>
                                    </div>
                                    <span class="help-inline"></span>
                                </div>
                            </div>
                            <div id="group-location" class="control-group">
                                <div class="controls service-add-input">
                                    <div class="input-prepend">
                                        <span class="add-on">Địa điểm</span>
                                        <select name="location">
                                            @foreach (var item in SmallShop.Services.Implements.UtilityService.GetCities())
                                            {
                                                if (Model.Location == item.Name)
                                                {
                                                <option selected="selected" value="@item.Name">@item.Name</option>
                                                }
                                                else
                                                {
                                                <option value="@item.Name">@item.Name</option>
                                                }
                                            }
                                        </select>
                                    </div>
                                    <span class="help-inline"></span>
                                </div>
                            </div>
                            <div id="group-price" class="control-group">
                                <div class="controls service-add-input">
                                    <div class="input-prepend input-append">
                                        <span class="add-on">Giá</span>
                                        <input name="price" class="input-large" id="appendedPrependedInput" value="@(Model.Price / 1000)" type="text">
                                        <span class="add-on">&nbsp;.000 đ</span>
                                    </div>
                                    <span class="help-inline"></span>
                                </div>
                            </div>
                            <div id="group-category" class="control-group">
                                <div class="controls service-add-input">
                                    <div class="input-prepend">
                                        <span class="add-on">Danh mục</span>
                                        <select name="cateID">
                                            @foreach (var item in listCate)
                                            {
                                                if (Model.CategoryID == item.ID)
                                                {
                                                <option selected="selected" value="@item.ID">@item.Name</option>
                                                }
                                                else
                                                {
                                                <option value="@item.ID">@item.Name</option>
                                                }
                                            }
                                        </select>
                                    </div>
                                    <span class="help-inline"></span>
                                </div>
                            </div>
                            <div id="group-end-date" class="control-group">
                                <div class="controls service-add-input">
                                    <div class="input-prepend input-append">
                                        <span class="add-on">Ngày hết hạn</span>
                                        <div class="input-append date" id="dp" data-date="@Model.EndDate.ToString("dd-MM-yyyy")" data-date-format="dd-mm-yyyy">
                                            <input class="span2" style="width:200px" readonly name="endDate" id="input-date" size="16" type="text" value="@Model.EndDate.ToString("dd-MM-yyyy")">
                                            <span class="add-on"><i class="icon-th"></i></span>
                                        </div>
                                    </div>
                                    <span class="help-inline"></span>
                                </div>
                            </div>
                            <!-- Button -->
                            <div class="control-group">
                                <div class="controls service-add-input">
                                    <button id="btn-post" type="submit" name="post" class="btn btn-primary">Đăng tin cần người</button>
                                </div>
                            </div>
                        </fieldset>
                    }
                </div>
            </div>
            <div class="span4 sidebar">
                <div class="service-detail-box sidebar-block" id="service-detail-creator">
                    <div class="container-header">
                        Hướng dẫn đăng yêu cầu
                    </div>
                    <div class="service-help">
                        <ul>
                            <li>Tiêu đề và mô tả rõ ràng, chi tiết.</li>
                            <li>Giá yêu cầu hợp lý.</li>
                            <li>Khi hết hạn yêu cầu sẽ không được hiển thị</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var nowTemp = new Date();
        var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
        $('#dp').datepicker({
            onRender: function (date) {
                return date.valueOf() < now.valueOf() ? 'disabled' : '';
            }
        });
        $('#area-des').wysihtml5({
            "font-styles": false
        });
    });
</script>